<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <title>新增收银员</title>
    <link rel="stylesheet" href="../../styles/h5/reset.min.css"/>
    <link rel="stylesheet" href="../../styles/h5/errortankuang.css"/>
    <!--以上为公共css样式-->
    <link rel="stylesheet" href="../../styles/h5/index.css"/>

    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery-1.9.1.min.js"></script>
    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery.modal.js"></script>
    <!--以上为公共js文件-->
</head>
<body>
<div class="zz-top"></div>
<div class="zz-list">
    <ul>
        <li>
            <span class="zz-left">收银员姓名</span
            ><input class="zz-code-num zz-payee-name" type="text" placeholder="请填写收银员姓名" maxlength="5"/>
        </li>
        <li>
            <span class="zz-left">联系电话</span
            ><input class="zz-code-num zz-phone-code" type="tel" placeholder="请填写手机号，紧急情况联系" maxlength="11"/>
        </li>
    </ul>
</div>
<input class="footer zz-footTop" type="button" value="下一步">
</body>

<script charset="utf-8" type="text/javascript" src="../../scripts/h5/utils.js"></script>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/index.js"></script>
<script charset="utf-8" type="text/javascript">

    var queryURLParameter = utils.queryURLParameter();

    $footer.click(function () {
        //只能中 文 长度2-5之间;
        if (!utils.effectiveName($payee_name.val(), $footer)) {
            return false;
        }

        //判断手机号  
        if(!utils.effectivePhone($phone_code.val(), $footer)){
        	return false;
        }

        var storeId = queryURLParameter.storeId;
        var name = $payee_name.val();
        var telephoneNo = utils.removeSpace($phone_code.val());
        
        new $.modal({
            content: "加载中",
            animation: true//调用动画
        }).show();
		//$footer.attr("disabled", "true");
        $.ajax({
            //点击立即收款 传递四个参数data 得到两个参数放到下个页面
            url: utils.ajaxUrl()+"h5/cashier/receiver/addCashier",
            async: false,
            data: {
                storeId: storeId,
                name: name,
                telephoneNo: telephoneNo
            },
            type: 'get',
            success: function (res) {
            	//console.log(res);
        		var res = JSON.parse(res);
        		//console.log(res);
                if (res && res.retCode == '0000') {
                    var userId = res["userId"];
                    window.location.href = "../../html/h5/requestCashier.html?storeId=" + queryURLParameter.storeId + "&toreShortName=" + queryURLParameter.toreShortName + "&name=" + name + "&userId=" + userId;
					//$footer.removeAttr("disabled");
					new $.modal({
            			animation: true,//调用动画
        			}).hide();
                }else{
                	new $.modal({
            			animation: true,//调用动画
        			}).hide(0);
                    new $.modal({
                        content: res.retMsg,//弹框内容
                        showcontent: true,//false为弹出框组件二，true为弹出框组件一

                    }).show($footer);
                    
                }
            }
        });
    })

</script>
</html>